import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/*
    不可变集合
 */
public class Main {
    public static void main(String[] args) {
        List<String> list = List.of("张三", "李四", "王五", "赵六");
        System.out.println(list.get(0));
        System.out.println(list.get(1));
        System.out.println(list.get(2));
        System.out.println(list.get(3));
        System.out.println("----------------------");
        for (String s : list) {
            System.out.println(s);
        }
        System.out.println("----------------------");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        System.out.println("----------------------");
        Iterator<String> it = list.iterator();
        while(it.hasNext()){
            String next = it.next();
            System.out.println(next);
        }
        System.out.println("----------------------");

        //不可变集合只能遍历不能修改 增加 删除
        // list.remove("李四");
        //
        // list.add("123");
        // list.set(0, "aa");

    }
}